#!/usr/bin/env python
# -*- coding=utf8 -*-
"""
# Author: bighu
# Created Time : 2021年12月25日 星期六 20时06分40秒
# File Name: decode_session.py
# Description:
"""

#!/usr/bin/env python3
import sys
import zlib
from base64 import b64decode
from flask.sessions import session_json_serializer
from itsdangerous import base64_decode


def decryption(payload):
    payload, sig = payload.rsplit(b'.', 1)
    payload, timestamp = payload.rsplit(b'.', 1)

    decompress = False
    if payload.startswith(b'.'):
        payload = payload[1:]
        decompress = True

    try:
        payload = base64_decode(payload)
    except Exception as e:
        raise Exception('Could not base64 decode the payload because of '
                        'an exception')

    if decompress:
        try:
            payload = zlib.decompress(payload)
        except Exception as e:
            raise Exception('Could not zlib decompress the payload before '
                            'decoding the payload')

    return session_json_serializer.loads(payload)

print(decryption(b'.eJxFkMtqwzAQRX-lzDoLS3E2hixc3BgXNEIgR0ibkIdjS7JTcBLsKuTfK1Jo1_fOuZx5wO48NtcOstt4bxawsyfIHvB2gAy0qldItxbdu8cSPUpGUGnCVTUx13sctj2GaubSdLw4WVT1Estq0qH6xuBnXvglLz_7mMV7NmvZJliIoINOUW6sify4kTKqKYs9U7LJuDzlygxafgQt84Q547hsZxbyVDtGuMxTJo0z0lMs4o7LCaNiDc8FHK_jeXf78s3lX0EeU16Iicne86Lv0GmilVhFDNG0TqLegEpQpDWJOparmrB2_cLZYd82fyRTzlshfpPLfogBHGzb3WEB92szvv4GJIHnD4vEazE.YcgkFw.yS7PtMHpjz4nCmbSxM2_3h1wi6c'))
